import { defineStore } from 'pinia'

export const useUserStore = defineStore({
  id: 'pure-userStore',
  state: () => {
    return {
      code: '',
      fieldGroup: {},
    }
  },
  actions: {
    setCode(data) {
      uni.setStorageSync('code', data)
      this.code = data
    },
    setField(data) {
      uni.setStorageSync('field', data)
      this.fieldGroup = data
    },
    getField() {
      if (this.fieldGroup.tag_id) {
        return this.fieldGroup
      } else {
        return uni.getStorageSync('field')
      }
    },
  },
})
